Merge "parserTests: Use a mock parser during article insertion"
[lhc/web/wiklou.git] / tests / parser / ParserTestRunner.php
index e433c2e..04c142a 100644 (file)
@@ -426,7 +426,7 @@ class ParserTestRunner {
         * @param ScopedCallback|null A ScopedCallback to consume
         * @return ScopedCallback
         */
-       protected function createTeardownObject( $teardown, $nextTeardown ) {
+       protected function createTeardownObject( $teardown, $nextTeardown = null ) {
                return new ScopedCallback( function() use ( $teardown, $nextTeardown ) {
                        // Schedule teardown snippets in reverse order
                        $teardown = array_reverse( $teardown );
@@ -1503,7 +1503,14 @@ class ParserTestRunner {
                        throw new MWException( "duplicate article '$name' at $file:$line\n" );
                }
 
+               // Use mock parser, to make debugging of actual parser tests simpler.
+               // But initialise the MessageCache clone first, don't let MessageCache
+               // get a reference to the mock object.
+               MessageCache::singleton()->getParser();
+               $restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
                $status = $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
+               $restore();
+
                if ( !$status->isOK() ) {
                        throw new MWException( $status->getWikiText( false, false, 'en' ) );
                }